package com.yiwei.hdb.api.requestInfo;

import com.yiwei.hdb.api.Api;
import com.yiwei.hdb.api.bean.DealDetailBean;
import com.yiwei.hdb.api.bean.PointLogBean;
import com.yiwei.hdb.api.callback.PointLogContract;
import com.yiwei.hdb.api.callback.YouhuiSelectContract;
import com.yiwei.hdb.util.Network;
import com.yiwei.hdb.util.RxLifeUtil;
import com.yiwei.hdb.util.ToastUtil;

/**
 * Created by Administrator on 2017/5/14.
 */

public class YouhuiSelectRequest extends BaseRequest<YouhuiSelectContract.View> implements YouhuiSelectContract.Presenter<YouhuiSelectContract.View> {

    public static YouhuiSelectRequest create() {
        return new YouhuiSelectRequest();
    }


    @Override
    public void getYouhui(int page, int pageSize, int useStatus) {
        if (!Network.checkNetwork(BaseContext)) {
            ToastUtil.makeText(BaseContext, networkFail);
            return;
        }
        mView.onRequestStart();
        DealDetailBean bean = new DealDetailBean();
        bean.page = page;
        bean.pagesize = pageSize;
        bean.use_status = useStatus;
        Api.api_service.getBonus(bean).compose(RxLifeUtil.checkOn(BaseContext)).
                doFinally(() -> {
                    try {
                        mView.complete();

                    } catch (NullPointerException e) {

                    }
                }).
                subscribe(result -> {
                    mView.getYouhuiSuccess(page, result);
                });
    }
}
